﻿using RPAVIEW.util;
using RPAVIEW.views.controlLibrary;
using SUNRPA.CONTROLS.IMPL.domain.flowItemParam;
using SUNRPA.CONTROLS.IMPL.util;
using System.IO;
using System.Windows.Controls;
namespace RPAVIEW.views.EditPage.flows.ReadFileN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        public Input() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            this.filePath.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.saveType.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.encodeType.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
        }

        private void SelectFile(object sender, System.Windows.RoutedEventArgs e) {
            string path = string.Empty;
            Microsoft.Win32.OpenFileDialog openFileDlg = FileUtil.OpenFileSelectDialog(".txt", "*.*|*.*", path);
            // 调用ShowDialog方法显示对话框
            openFileDlg.ShowDialog();
            // 显示名称
            path = openFileDlg.FileName;
            if(!File.Exists(path)) {
                return;
            }
            ReadFileNParam param = WindowUtil.GetWindow<FlowEditWindow>().DataContext as ReadFileNParam;
            param.FilePath = path;
        }
    }
}
